package k8sresource

type PodInfo struct {
	MetaData Metadata  `json:"metadata"`
	Spec     PodSpec   `json:"spec"`
	Status   PodStatus `json:"status"`
}

type DeploymentInfo struct {
	MetaData Metadata         `json:"metadata"`
	Spec     DeploymentSpec   `json:"spec"`
	Status   DeploymentStatus `json:"status"`
}

type Metadata struct {
	Name              string            `json:"name"`
	Namespace         string            `json:"namespace"`
	UID               string            `json:"uid"`
	CreationTimestamp string            `json:"creationTimestamp"`
	Labels            map[string]string `json:"labels"`
	Annotations       map[string]string `json:"annotations"`
	OwnerReferences   []OwnerReference  `json:"ownerReferences"`
}

type OwnerReference struct {
	APIVersion         string `json:"apiVersion"`
	Kind               string `json:"kind"`
	Name               string `json:"name"`
	UID                string `json:"uid"`
	Controller         bool   `json:"controller"`
	BlockOwnerDeletion bool   `json:"blockOwnerDeletion"`
}

type DeploymentSpec struct {
	Replicas int32              `json:"replicas"`
	Selector LabelSelector      `json:"selector"`
	Strategy DeploymentStrategy `json:"strategy"`
	Template PodTemplateSpec    `json:"template"`
}

type LabelSelector struct {
	MatchLabels map[string]string `json:"matchLabels"`
}
type DeploymentStrategy struct {
	Type string `json:"type"` // e.g., "RollingUpdate", "Recreate"
}

type PodTemplateSpec struct {
	Metadata Metadata `json:"metadata"`
	Spec     PodSpec  `json:"spec"`
}

type DeploymentStatus struct {
	Replicas            int32       `json:"replicas"`
	ReadyReplicas       int32       `json:"readyReplicas"`
	AvailableReplicas   int32       `json:"availableReplicas"`
	UnavailableReplicas int32       `json:"unavailableReplicas"`
	DurationTime        string      `json:"durationTime,omitempty"`
	Conditions          []Condition `json:"conditions"`
}
type Condition struct {
	Type           string `json:"type"`   // e.g., "Available", "Progressing"
	Status         string `json:"status"` // e.g., "True", "False", "Unknown"
	LastUpdateTime string `json:"lastUpdateTime"`
	Reason         string `json:"reason"` // e.g., "MinimumReplicasAvailable"
}

type PodSpec struct {
	NodeName   string      `json:"nodeName,omitempty"`
	Containers []Container `json:"containers"`
}
type Container struct {
	Name      string          `json:"name"`
	Image     string          `json:"image"`
	Args      []string        `json:"args"`
	Ports     []ContainerPort `json:"ports"`
	Env       []EnvVar        `json:"env"`
	Resources Resources       `json:"resources"`
}

type ContainerPort struct {
	Name          string `json:"name"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol"` // default is "TCP"
}

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"` // default is ""
}

type Resources struct {
	Requests map[string]string `json:"requests"` // e.g., {"cpu": "100m", "memory": "256Mi"}
	Limits   map[string]string `json:"limits"`   // e.g., {"cpu": "200m", "memory": "512Mi"}
}

type PodStatus struct {
	Phase             string            `json:"phase"` // e.g., "Running", "Pending", "Succeeded", "Failed", "Unknown"
	PodIP             string            `json:"podIP"`
	ContainerStatuses []ContainerStatus `json:"containerStatuses"`
	DurationTime      string            `json:"durationTime,omitempty"`
}

type ContainerStatus struct {
	Ready bool `json:"ready"`
}
